package com.hzlj.position.locate.differentiation;


import cn.hutool.core.util.ObjectUtil;
import com.fz.common.base.core.RequestHolder;
import com.fz.common.base.exception.PubException;
import com.hzlj.position.locate.common.dto.differentiationConfig.DifferentiationConfigExtDTO;
import com.hzlj.position.locate.common.dto.differentiationConfig.DifferentiationConfigQueryResultDTO;
import com.hzlj.position.locate.common.dto.differentiationData.DifferentiationDataQueryResultDTO;
import com.hzlj.position.locate.common.enums.DifferentiationDataType;

public interface DifferentiationService {
    /**
     * 获取分化类型
     */
    DifferentiationDataType getType();

    /**
     * 处理Differentiation数据
     */
    default void handleDifferentiationData(DifferentiationDataQueryResultDTO data) {
    }

    /**
     * 获取角色
     */
    default String getNoticeWorkerRoles() {
        Object obj = RequestHolder.get();
        if (!(obj instanceof DifferentiationConfigQueryResultDTO)) {
            return "SFSGLG,SFSGZG";
        }
        return ((DifferentiationConfigQueryResultDTO) obj).getRoles();
    }
    /**
     * 重试配置
     */
    default DifferentiationConfigExtDTO getDifferentiationConfigExt() {
        Object obj = RequestHolder.get();
        if (!(obj instanceof DifferentiationConfigQueryResultDTO)) {
            throw new PubException("未配置ext");
        }
        DifferentiationConfigExtDTO ext = ((DifferentiationConfigQueryResultDTO) obj).getExt();

        if (ObjectUtil.isEmpty(ext)) {
            throw new PubException("未配置ext");
        }
        return ext;
    }
}
